﻿using System.Collections.Generic;
using JSM.DataStore;

namespace JSM.Test.MockUp
{
	class UnitTestDataStoreProvider : IDataStoreProvider
	{
		private readonly Dictionary<string, object> _store;

		public UnitTestDataStoreProvider()
		{
			_store = new Dictionary<string, object>();
		}

		/// <summary>
		/// Sets the data to the data store.
		/// </summary>
		/// <param name="key">
		/// The key of the data.
		/// </param>
		/// <param name="value">
		/// The value of the data.
		/// </param>
		public void SetData(string key, object value)
		{
			_store.Add(key, value);
		}

		/// <summary>
		/// Gets the data of the data store.
		/// </summary>
		/// <param name="key">
		/// The key of the data.
		/// </param>
		/// <returns>
		/// The data from the data store as <see cref="object"/>.
		/// </returns>
		public object GetData(string key)
		{
			return _store[key];
		}

		/// <summary>
		/// Checks whether an data entry exists for the given key.
		/// </summary>
		/// <param name="key">
		/// The key of the data.
		/// </param>
		/// <returns>
		/// true if the data store contains data for the given key, otherwise false.
		/// </returns>
		public bool ContainsData(string key)
		{
			return _store.ContainsKey(key);
		}
	}
}
